<?php
	include('db_connection.php');
	class User_unsubscribe{
	
		function unSubscribeUser(){
			if(trim($_POST['user_email']) != '') {
				$select_subscribe = "SELECT * FROM tbl_user WHERE email='".$_POST['user_email']."'";		
				$query_subscribe = mysql_query($select_subscribe) or die(mysql_error());

				$count_row_subscribe = mysql_num_rows($query_subscribe);
				
				if($count_row_subscribe>0){
						
						$update = "UPDATE tbl_user SET is_active='0',update_ts=now() WHERE email='".$_POST['user_email']."'";						
						$user_update = mysql_query($update) or die(mysql_error());
						$unSubscribe_url_msg = "Your Account is now Unsubscribe";
						return $unSubscribe_url_msg;
					
				}else{
					
		
					$unSubscribe_url_msg = "This Email is not exist in our system.";
					return $unSubscribe_url_msg;					
				}
				
			}else{
				$val_msg = '';
				if(trim($_POST['user_email']) == ''){
					$val_msg = 'Email Is Required';
				}
				return $val_msg;
			}
		}
	}
?>